package com.dd.stack.rpc.dubbo.provider.service.impl.rpc;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dd.stack.common.util.Result;
import com.dd.stack.common.util.response.ApiResponse;
import com.dd.stack.rpc.dubbo.api.DataObjectApi;
import com.dd.stack.rpc.dubbo.common.pijo.DataObjectRpcBO;
import com.dd.stack.rpc.dubbo.provider.mapper.DataObjectMapper;
import com.dd.stack.rpc.dubbo.provider.pijo.DataObjectDO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/3/8 9:29
 * @Description 提供远程过程调用DataObjectApi的实现
 */
@Service
@RequiredArgsConstructor
public class DataObjectRpcImpl implements DataObjectApi {

    private final DataObjectMapper dataObjectMapper;

    @Override
    public ApiResponse<DataObjectRpcBO> getOneById(Long id) {
        DataObjectDO dataObjectDO = dataObjectMapper.selectById(id);
        DataObjectRpcBO BO = new DataObjectRpcBO();
        BeanUtils.copyProperties(dataObjectDO, BO);
        return ApiResponse.success(BO);
    }
}
